package com.jrmf.redenvelopes.order.service.impl;

import com.jrmf.redenvelopes.order.service.AsyncService;
import com.jrmf.redenvelopes.order.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Date;
@Service
public class AsyncServiceImpl implements AsyncService {

    private static final Logger logger = LoggerFactory.getLogger(AsyncServiceImpl.class);

    @Override
    @Async("taskExecutor")
    public void executeAsync() {
        logger.info("start executeAsync");
        try{
            logger.info(DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm")+"开始执行任务");
            //执行跑批任务，各自执行一天的，互相独立，各不影响
        }catch(Exception e){
            e.printStackTrace();
        }
        logger.info("end executeAsync");
    }
}
